package com.my.concurrency.demo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: marshal
 * @date: 2022-09-29 14:58
 */
public class ThirdThread {
    public static void main(String[] args) {
        var rt = new ThirdThread();
        var futureTask = new FutureTask<>(() -> {
            var i = 0;
            for (; i < 100; i++) {
                System.out.println(Thread.currentThread().getName() + " " + i);
            }
            return i;
        });
        for (var i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + " 的循环变量i的值： " + i);
        }
        try {
            System.out.println("子线程的返回值： " + futureTask.get());
        } catch (ExecutionException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
